//
//  JaneGProductListController.m
//  EPA
//
//  Created by lanou3g on 16/4/23.
//  Copyright © 2016年 张静. All rights reserved.
//

#import "JaneGProductListController.h"
#import "JaneGProductModel.h"
#import "JaneNetWorkRequestManager.h"
@interface JaneGProductListController ()
@property (nonatomic,strong) NSString *urlStr;
@end

@implementation JaneGProductListController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadFromContentID:nil];
    self.navigationItem.title = @"良品详情";
    // Do any additional setup after loading the view.
}
- (void)loadFromContentID:(NSString *)contentid {
    [JaneNetWorkRequestManager requestURL:[NSURL URLWithString:SHOPDETAILLIST_URL] RequestMethod:CK_POST Params:@{@"auth":@"XZU7RH7m1861DC8Z8H8HvkTJxQMGoPLGO9zo4XDA0cWP22NdFSh9d7fo",@"client":@"1",@"contentid":self.gModel.contentid,@"deviceid":@"6D4DD967-5EB2-40E2-A202-37E64F3BEA31",@"version":@"3.0.6"} Result:^(NSData *data, NSURLResponse *response, NSError *error) {
        if (data) {
            NSMutableDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSDictionary *dataDict = jsonDict[@"data"];
            NSDictionary *postDict = dataDict[@"postsinfo"];
            NSDictionary *shareDict = postDict[@"shareinfo"];
            self.urlStr = shareDict[@"url"];
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            [self createWebView];
        });
    }];
}
- (void)createWebView {
    UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    webView.backgroundColor = [UIColor grayColor];
    [self.view addSubview:webView];
    [webView  loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlStr]]];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
